package com.qdu.servlet;

import com.qdu.entity.Users;
import com.qdu.service.UsersService;
import com.qdu.service.impl.UsersServiceImpl;
import java.io.IOException;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@WebServlet("/sbls")
public class UsersLoginServlet extends HttpServlet {
UsersService ss = new UsersServiceImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        //1. 获取请求参数
        int uno = Integer.parseInt(req.getParameter("Uno"));
        String upwd = req.getParameter("Upwd");

        //2. 执行业务逻辑              
        Users users = ss.loginUsers(uno, upwd);

        //3. 生成动态响应
        if(users!=null){
        req.setAttribute("users", users);
        req.getRequestDispatcher("/index.jsp").forward(req, resp);
    }else{
             resp.sendRedirect("fail.html");
        }
    }
}
